/* api统一管理 */
import ajax from './ajax.js'; //	引入ajax

let api = {}; //	用于存储所有api方法

api.getClassify = (params) => ajax.get('/api/classify/get?projectId=181'); //	获取所有分类

api.getArtFromClass = (params) =>
  ajax.get(
    `/api/blog/searchByClassifyId?id=${params.classifyId}&projectId=181&limit=${params.limit}&offset=${params.offset}`
  ); //	根据分类ID获取文章

api.getArtByBlogId = (params) =>
  ajax.get(`/api/blog/search?id=${params}&projectId=181`); //	根据博客id获取博客

api.getSearchArtByKeyWord = (params) =>
  ajax.get(`/api/blog/searchByInput?keyword=${params}&projectId=181`); //	根据关键词搜索

api.getMyBlog = (params) =>
  ajax.get(
    `/api/blog/getMyBlog?projectId=181&limit=${params.limit}&offset=${params.offset}`
  );

api.getMyInterstAuthor = (params) => ajax.get(`/api/user/getLikeUser`); // 获取我关注的作者列表

api.getMyLikeBlog = (params) => ajax.get(`/api/user/getLikeBlog`); // 获取我赞过的博客

api.getCommentByBlogId = (params) =>
  ajax.get(
    `/api/comment/get?id=${params.blogId}&projectId=181&limit=${
      params.limit || 10
    }&offset=${params.offset || 0}`
  ); // 获取博客的评论

api.deleteBlogById = (params) => ajax.delete('/api/blog/deleteBlog', params); //	根据id删除博客

api.InterstAuthor = (params) => ajax.post('/api/user/follow', params); // 关注/取消关注作者

api.toRegister = (params) => ajax.post('/api/user/register', params); // 用户注册

api.toLogin = (params) => ajax.post('/api/user/login', params); // 用户登录

api.editPerInfo = (params) => ajax.put(`/api/user/edit`, params); // 修改用户个人信息

api.createBlog = (params) => ajax.post('/api/blog/create', params); // 发布博客

api.cancelLikeBlog = (params) => ajax.post(`/api/blog/likeBlog`, params); // 点赞/取消点赞博客

api.commentBlog = (params) => ajax.post(`/api/comment/create`, params); //	评论博客

api.uploadImg = (params) => ajax.post(`/api/imgUpload`, params); // 上传图片
export default api;
